﻿using System.Web.Http;
using System.Web.Http.Cors;

namespace Back_end
{
    public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
			// Web API 配置和服务
			//config.SuppressDefaultHostAuthentication();
			//config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

			var cors = new EnableCorsAttribute("*", "*", "*");
            config.EnableCors();

			// Web API 路由
			config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
        }
    }
}
